package com.wut.core.config.exception;

import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpStatus;
import lombok.Data;

@Data
public class GlobalException extends RuntimeException {

    private int code;

    public GlobalException() {
        super();
        this.code = HttpStatus.HTTP_INTERNAL_ERROR;
    }

    public GlobalException(String message) {
        super(message);
        this.code = HttpStatus.HTTP_INTERNAL_ERROR;
    }

    public GlobalException(String formatMessage, Object... params) {
        super(StrUtil.format(formatMessage, params));
        this.code = HttpStatus.HTTP_INTERNAL_ERROR;
    }

    public GlobalException(String message, int code) {
        super(message);
        this.code = code;
    }

    public GlobalException(String message, Throwable e, int code) {
        super(message, e);
        this.code = code;
    }
}